package es.gesfutbol.domini.implementacio;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import es.gesfutbol.domini.IComentari;

@Entity
@Table(name="comentari")
public class Comentari implements IComentari {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3813681449430643496L;

	private Long idComentari;
	
	private String titol;
	
	private String missatge;
	
	private Penyista penyista;
	
	private Forum forum;

	private Date data;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="idComentari", nullable=false, precision=10, scale=0)
	public Long getIdComentari() {
		return idComentari;
	}

	public void setIdComentari(Long idComentari) {
		this.idComentari = idComentari;
	}
	
	@Column(name="titol", nullable=true, length=45)
	public String getTitol() {
		return titol;
	}

	public void setTitol(String titol) {
		this.titol = titol;
	}

	@Column(name="missatge", nullable=false, length=250)
	public String getMissatge() {
		return missatge;
	}

	public void setMissatge(String missatge) {
		this.missatge = missatge;
	}

	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="idPenyista" , nullable=false)
	public Penyista getPenyista() {
		return penyista;
	}

	public void setPenyista(Penyista penyista) {
		this.penyista = penyista;
	}

	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="idForum", nullable=false)
	public Forum getForum() {
		return forum;
	}

	public void setForum(Forum forum) {
		this.forum = forum;
	}

	@Temporal(TemporalType.DATE)
	@Column(name="data", nullable=false, length=11)
	public Date getData() {
		return data;
	}

	public void setData(Date data) {
		this.data = data;
	}
}